<!--
 * @Author: your name
 * @Date: 2021-12-07 16:18:10
 * @LastEditTime: 2021-12-07 17:23:41
 * @LastEditors: sueRimn
 * @Description: 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE
 * @FilePath: \front-end-algorithm\算法\二叉树的递归遍历.html
-->
<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>二叉树的递归遍历</title>
</head>

<body>

    <ul>
        <li>方法论：</li>
        <li>确定参数和返回值</li>
        <li>确定终止条件</li>
        <li>确定单一的循环体</li>

    </ul>
    <script>

        class Node {
            constructor(root, left, right) {
                this.root = root || 0;
                this.left = left || null;
                this.right = right || right;
            }
        }
        class nodeTree {
            constructor(root) {
                this.root = null;
            }
            //前序遍历-中左右
            /**
             * @name: 
             * @test: test font
             * @msg: 
             * @param {*} node
             * @return {*}
             */
            frontOrder(node = this.root) {
                let result = [];
                if (node) {
                    //中-左-右
                    result.push(this.root);
                    result.push(this.def(this.left));
                    result.push(this.def(this.right));
                }
                return result;
            }
            //中序遍历
            middleOrder(node = this.root) {
                let result = [];
                if (node) {
                    //左-中-右
                    result.push(this.def(this.left));
                    result.push(this.root);
                    result.push(this.def(this.right));
                }
            }

            endOrder(node = this.root) {
                let result = [];
                if (node) {
                    //左-中-右
                    result.push(this.def(this.left));
                    result.push(this.def(this.right));
                    result.push(this.root);
                }
            }
        }
    </script>
</body>

</html>